package com.oneguy.control.util;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by ZuoShu on 16/12/5.
 */
public class TextUtils {
    public static boolean isEmpty(String s) {
        return s == null || s.length() == 0;
    }

    public static String simpleFormatTime(long time) {
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        return sf.format(new Date(time));
    }

    public static String fixLength(String origin, int maxLength) {
        if (origin == null || origin.length() == 0) {
            return "";
        }

        if (origin.length() >= maxLength) {
            return origin;
        }

        StringBuilder sb = new StringBuilder(origin);
        for (int i = 0; i < maxLength - origin.length(); i++) {
            sb.append(" ");
        }
        return sb.toString();
    }
}
